<template>
    <el-container>
            <el-header style="height: 65px;background-color: #373D41">
<!--                <el-image-->
<!--                                style="float: left"-->
<!--                                src=""-->
<!--                                fit="fill"></el-image>-->
                <span class="title" >会议室系统管理员后台</span>
                <div class="header-avatar">
                    <el-avatar src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></el-avatar>
                    <el-dropdown>
                        <span class="el-dropdown-link">
                            {{userInfo.username}}
                            <i class="el-icon-arrow-down el-icon--right"></i>
                        </span>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item @click.native="logout">退出</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </div>
            </el-header>
            <el-container>
                <SideMenu></SideMenu>
                <el-main>
                    <Tabs></Tabs>
                    <router-view v-if="isRouterAlive"></router-view>
                </el-main>
            </el-container>
    </el-container>
</template>

<script>
    import SideMenu from "@/views/admin_inc/SideMenu";
    import Tabs from "@/views/admin_inc/Tabs";
    export default {
        name: "AdminHome",
        provide(){
            return{
                reload:this.reload
            }
        },
        data(){
          return  {
              isRouterAlive:true,
              userInfo:{
                  id:"",
                  username:"管理员",
                  gender:"",
                  tel:"",
                  role:""
              }
          }
        },
        components:{
            SideMenu,Tabs
        },
        mounted() {
            this.getUserInfo();
        },
        methods:{
            reload(){
              this.isRouterAlive = false
              this.$nextTick(function (){
                  this.isRouterAlive = true
              })
            },
            logout(){
                this.$axios({
                    method:"post",
                    url:"/logout"
                }).then( res =>{
                    localStorage.clear();
                    sessionStorage.clear();

                    this.$store.commit("resetState")
                    this.$router.push("/")
                })
            },
            getUserInfo(){
                this.userInfo.username=window.sessionStorage.getItem("username")
            }
        }
    }
</script>

<style scoped>
    .title{
        font-size: xx-large;
        float: left;
        color: white;
        font-family: "华文琥珀";
    }
    .header-avatar{
        float: right;
        width: 150px;
        display: flex;
        justify-content: space-around;
        align-items: center;

    }
    .el-dropdown-link {
        cursor: pointer;
        color: #409EFF;
    }
    .el-icon-arrow-down {
        font-size: 12px;
    }
    .el-container{
        margin: 0;
        padding: 0;
        height: 98vh;
    }
    .el-header{
        background-color: #B3C0D1;
        color: #333;
        text-align: center;
        line-height: 60px;
    }

    .el-aside {
        background-color: #D3DCE6;
        color: #333;
        line-height: 200px;
        text-align: left;
    }

    .el-main {
        background-color: white;
        color: #333;
        padding: 15px;
        text-align: left;
    }
    a{
        text-decoration: none;
    }

</style>
